home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / xmng_tmpl.pro < prev    next >
Text File  |  1997-07-08  |  6KB  |  184 lines

  1. ; $Id: xmng_tmpl.pro,v 1.4 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1991-1997, Research Systems, Inc.  All rights reserved.
  4. ;    Unauthorized reproduction prohibited.
  5. ;+
  6. ; NAME:
  7. ;    XMNG_TMPL
  8. ;
  9. ; PURPOSE:
  10. ;    This routine is a template for widgets that use the XManager.  Use
  11. ;    this template instead of writing your widget applications from
  12. ;    "scratch".
  13. ;
  14. ;    This documentation should be altered to reflect the actual 
  15. ;    implementation of the XMNG_TMPL widget.  Use a global search and 
  16. ;    replace to replace the word "Xmng_tmpl" with the name of the routine 
  17. ;    you would like to use.  The name should be no longer than "XMng_tmpl".
  18. ;    All the comments with a "***" in front of them should be read, decided 
  19. ;    upon and removed for your final copy of the XMng_tmpl widget
  20. ;    routine.
  21. ;
  22. ; CATEGORY:
  23. ;    Widgets.
  24. ;
  25. ; CALLING SEQUENCE:
  26. ;    XMNG_TMPL
  27. ;
  28. ; INPUTS:
  29. ;
  30. ; OPTIONAL INPUT PARAMETERS:
  31. ;
  32. ; KEYWORD PARAMETERS:
  33. ;    GROUP:    The widget ID of the widget that calls XMng_tmpl.  When this
  34. ;        ID is specified, the death of the caller results in the death
  35. ;        of Xmng_tmpl.
  36. ;
  37. ; OUTPUTS:
  38. ;
  39. ; OPTIONAL OUTPUT PARAMETERS:
  40. ;
  41. ; COMMON BLOCKS:
  42. ;
  43. ; SIDE EFFECTS:
  44. ;    Initiates the XMANAGER if it is not already running.
  45. ;
  46. ; RESTRICTIONS:
  47. ;
  48. ; PROCEDURE:
  49. ;    Create and register the widget and then exit.
  50. ;
  51. ; MODIFICATION HISTORY:
  52. ;    Created from a template written by: Steve Richards, January, 1991.
  53. ;-
  54.  
  55. ;*** Above is a comment template for all IDL library routines with some of the
  56. ;*** specifics for XMng_tmpl filled in.  All library routines should use this
  57. ;*** format so that the DOC_LIBRARY routine in IDL can be used to find out
  58. ;*** more about a given routine.  You should modify the above comments for 
  59. ;*** your application.  This header will then be displayed when DOC_LIBRARY is
  60. ;*** called for your routine.
  61.  
  62.  
  63.  
  64. ;------------------------------------------------------------------------------
  65. ;    procedure XMng_tmpl_ev
  66. ;------------------------------------------------------------------------------
  67. ; This procedure processes the events being sent by the XManager.
  68. ;*** This is the event handling routine for the XMng_tmpl widget.  It is 
  69. ;*** responsible for dealing with the widget events such as mouse clicks on
  70. ;*** buttons in the XMng_tmpl widget.  The tool menu choice routines are 
  71. ;*** already installed.  This routine is required for the XMng_tmpl widget to
  72. ;*** work properly with the XManager.
  73. ;------------------------------------------------------------------------------
  74. PRO XMng_tmpl_ev, event
  75.  
  76. WIDGET_CONTROL, event.id, GET_UVALUE = eventval        ;find the user value
  77.                             ;of the widget where
  78.                             ;the event occured
  79. IF N_ELEMENTS(eventval) EQ 0 THEN RETURN
  80. IF eventval EQ 'THEMENU' THEN BEGIN
  81. CASE event.value OF
  82.  
  83. ;*** here is where you would add the actions for your events.  Each widget
  84. ;*** you add should have a unique string for its user value.  Here you add
  85. ;*** a case for each of your widgets that return events and take the
  86. ;*** appropriate action.
  87.  
  88.   "XLoadct": XLoadct, GROUP = event.top            ;XLoadct is the library
  89.                             ;routine that lets you
  90.                             ;select and adjust the
  91.                             ;color palette being
  92.                             ;used.
  93.  
  94.   "XPalette": XPalette, GROUP = event.top        ;XPalette is the
  95.                             ;library routine that
  96.                             ;lets you adjust 
  97.                             ;individual color
  98.                             ;values in the palette.
  99.  
  100.   "XManagerTool": XMTool, GROUP = event.top        ;XManTool is a library
  101.                             ;routine that shows 
  102.                             ;which widget
  103.                             ;applications are 
  104.                             ;currently registered
  105.                             ;with the XManager as
  106.                             ;well as which
  107.                             ;background tasks.
  108.  
  109.   "Done": WIDGET_CONTROL, event.top, /DESTROY        ;There is no need to
  110.                             ;"unregister" a widget
  111.                             ;application.  The
  112.                             ;XManager will clean
  113.                             ;the dead widget from
  114.                             ;its list.
  115.  
  116.   ELSE: MESSAGE, "Event User Value Not Found"        ;When an event occurs
  117.                             ;in a widget that has
  118.                             ;no user value in this
  119.                             ;case statement, an
  120.                             ;error message is shown
  121. ENDCASE
  122. ENDIF
  123.  
  124. END ;============= end of XMng_tmpl event handling routine task =============
  125.  
  126.  
  127.  
  128. ;------------------------------------------------------------------------------
  129. ;    procedure XMng_tmpl
  130. ;------------------------------------------------------------------------------
  131. ; This routine creates the widget and registers it with the XManager.
  132. ;*** This is the main routine for the XMng_tmpl widget.  It creates the
  133. ;*** widget and then registers it with the XManager which keeps track of the 
  134. ;*** currently active widgets.  
  135. ;------------------------------------------------------------------------------
  136. PRO XMng_tmpl, GROUP = GROUP
  137.  
  138. ;*** If XMng_tmpl can have multiple copies running, then delete the following
  139. ;*** line and the comment for it.  Often a common block is used that prohibits
  140. ;*** multiple copies of the widget application from running.  In this case, 
  141. ;*** leave the following line intact.
  142.  
  143. IF(XRegistered("XMng_tmpl") NE 0) THEN RETURN        ;only one instance of
  144.                             ;the XMng_tmpl widget
  145.                             ;is allowed.  If it is
  146.                             ;already managed, do
  147.                             ;nothing and return
  148.  
  149. ;*** Next the main base is created.  You will probably want to specify either
  150. ;*** a ROW or COLUMN base with keywords to arrange the widget visually.
  151.  
  152. XMng_tmplbase = WIDGET_BASE(TITLE = "XMng_tmpl")    ;create the main base
  153.  
  154. ;*** Here some default controls are built in a menu.  The descriptions of these
  155. ;*** procedures can be found in the XMng_tmpl_ev routine above.  If you would
  156. ;*** like to add other routines or remove any of these, remove them both below
  157. ;*** and in the XMng_tmpl_ev routine.
  158.  
  159. menu = CW_PdMenu(XMng_tmplbase, /RETURN_NAME, $
  160.                  ['1\File',$
  161.                   '2\Done',$
  162.                   '1\Tools',$
  163.                   '0\XLoadct',$
  164.                   '0\XPalette',$
  165.                   '2\XManagerTool'], UVALUE='THEMENU')
  166.  
  167.  
  168. ;*** Typically, any widgets you need for your application are created here.
  169. ;*** Create them and use XMng_tmplbase as their base.  They will be realized
  170. ;*** (brought into existence) when the following line is executed.
  171.  
  172. WIDGET_CONTROL, XMng_tmplbase, /REALIZE            ;create the widgets
  173.                             ;that are defined
  174.  
  175. XManager, "XMng_tmpl", XMng_tmplbase, $            ;register the widgets
  176.         EVENT_HANDLER = "XMng_tmpl_ev", $    ;with the XManager
  177.         GROUP_LEADER = GROUP, /NO_BLOCK        ;and pass through the
  178.                             ;group leader if this
  179.                             ;routine is to be 
  180.                             ;called from some group
  181.                             ;leader.
  182.  
  183. END ;==================== end of XMng_tmpl main routine =======================
  184.